package com.dao.t;

import com.javaweb.common.StringUtils;
import com.javaweb.config.SpringConfig;
import com.javaweb.dao.UserDao;
import com.javaweb.model.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;

/**
 * @desc:
 * @author: Ping
 * @date: 2024/9/25 10:28
 */

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes={SpringConfig.class})
public class aoptest {
    @Autowired
    ApplicationContext ctx ;

    @Autowired
    UserDao userDao ;

    @Test
    public void testSimpleBeforeMethods() {
        userDao.selectCountAll() ;

    }

    @Test
    public void testAfterAllInsertMethods() {

        userDao.insert(new User().setName("张三")
                .setPassword(StringUtils.md5Encoder("123456", StringUtils.getSalt("张三")))
                .setSalt(StringUtils.getSalt("张三"))
                .setGender(0)
                .setCreateTime(new Date())
        )  ;

    }

    @Test
    public void testAround() {
        userDao.selectCountAll() ;
    }



}